package com.edu.study.base.wordBookMember.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.wordBookMember.domain.WordBookMember;
import com.edu.study.base.wordBookMember.service.IWordBookMemberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员的词书Controller
 * 
 * @author zw
 * @date 2022-04-19
 */
@RestController
@RequestMapping("/WordBookMember/WordBookMember")
public class WordBookMemberController extends BaseController
{
    @Autowired
    private IWordBookMemberService wordBookMemberService;

    /**
     * 查询会员的词书列表
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:list')")
    @GetMapping("/list")
    public TableDataInfo list(WordBookMember wordBookMember)
    {
        startPage();
        List<WordBookMember> list = wordBookMemberService.selectWordBookMemberList(wordBookMember);
        return getDataTable(list);
    }

    /**
     * 导出会员的词书列表
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:export')")
    @Log(title = "会员的词书", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WordBookMember wordBookMember)
    {
        List<WordBookMember> list = wordBookMemberService.selectWordBookMemberList(wordBookMember);
        ExcelUtil<WordBookMember> util = new ExcelUtil<WordBookMember>(WordBookMember.class);
        return util.exportExcel(list, "WordBookMember");
    }

    /**
     * 获取会员的词书详细信息
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(wordBookMemberService.selectWordBookMemberById(id));
    }

    /**
     * 新增会员的词书
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:add')")
    @Log(title = "会员的词书", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WordBookMember wordBookMember)
    {
        return toAjax(wordBookMemberService.insertWordBookMember(wordBookMember));
    }

    /**
     * 修改会员的词书
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:edit')")
    @Log(title = "会员的词书", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WordBookMember wordBookMember)
    {
        return toAjax(wordBookMemberService.updateWordBookMember(wordBookMember));
    }

    /**
     * 删除会员的词书
     */
    @PreAuthorize("@ss.hasPermi('WordBookMember:WordBookMember:remove')")
    @Log(title = "会员的词书", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wordBookMemberService.deleteWordBookMemberByIds(ids));
    }
}
